package com.xiaoxin.service;

import com.xiaoxin.dubbo.api.UserApi;
import com.xiaoxin.interceptor.UserHolder;
import com.xiaoxin.model.domain.User;
import com.xiaoxin.model.vo.HuanXinUserVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author xiaoxiaode
 * @date 2021-09-07-19:52
 **/
@Service
public class HuanXinService {


    @DubboReference
    private UserApi userApi;

    /*
    * 查询当前用户的环信账号
    * methods:
    * 1: 获取当前用户id,根据规则拼接
    * 2: 获取当前用户id,查询用户具体信息
    * */
    public HuanXinUserVo findHuanxinUser() {
        Long userId = UserHolder.getId();
        User user=userApi.findById(userId);
        if(user==null){
            return null;
        }
        return  new HuanXinUserVo(user.getHxUser(),user.getHxPassword());
    }
}
